package com.company;

import java.util.Scanner;

public class ArrDemo2 {
    public static void main(String[] args) {
        String[][][] namelist={{{"张阳","李风","陈飞"},{"乐乐","飞飞","小曼"}},
                {{"Jack","Kimi"},{"Lucy","Lily","Rose"}},
                {{"徐璐璐","陈海"},{"李丽丽","陈海清"}}};
        for(int i=0;i<namelist.length;i++)
        {
            for(int j=0;j<namelist[i].length;j++)
            {
                for(int k=0;k<namelist[i][j].length;k++)
                {
                    System.out.println("namelist["+i+"]["+j+"]["+k+"]="+namelist[i][j][k]);
                }
            }
        }
        //创建一个二维矩阵
        int[][] matrix=new int[5][5];
        //随机分配值
        for(int i=0;i<matrix.length;i++)
        {
            for(int j=0;j<matrix[i].length;j++)
            {
                matrix[i][j]=(int)(Math.random()*10);
            }
        }
        System.out.println("下面是程序生成的矩阵\n");
        //遍历二维矩阵并输出
        for(int k=0;k<matrix.length;k++)
        {
            for(int g=0;g<matrix[k].length;g++)
            {
                System.out.print(matrix[k][g]+"");
            }
            System.out.println();
        }
        // 声明数组
        int[] prices = new int[5];
        double[][] class_score={{10.0,99,99},{100,98,97},{100,100,99.5},{99.5,99,98.5}};
        System.out.println("第二行第二列元素的值："+class_score[1][1]);
        System.out.println("第四行第一列元素的值："+class_score[3][0]);
        for(int i=0;i<class_score.length;i++)
        {    //遍历行
            for(int j=0;j<class_score[i].length;j++)
            {
                System.out.println("class_score["+i+"]["+j+"]="+class_score[i][j]);
            }
        }
        int maxPrice = 0;
        int avgPrice = 0;
        int sumPrice = 0;
        Scanner input = new Scanner(System.in);
        for(int i=0; i<5; i++){
            prices[i] = input.nextInt();
        }
        // 计算价格最大值
        maxPrice = prices[0];
        for (int index=1; index<prices.length; index++) {
            sumPrice += prices[index]; //汇总价格
            if(prices[index] > maxPrice) {
                maxPrice = prices[index];
            }
        }

        //计算品均值
        avgPrice=sumPrice/prices.length;
        System.out.println("本货架上商品的总价格为："+sumPrice+" 平均价格为："+avgPrice+" 最高价格为："+maxPrice);
    }
}
